﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AC.Window.Helper
{
    public static class Config
    {
        private static Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        public static string Read(string key)
        {
            string result = string.Empty;
            try
            {
                if (config.AppSettings.Settings[key] != null)
                    result = config.AppSettings.Settings[key].Value;
            }
            catch (Exception ex)
            {
                result = string.Empty;
            }
            return result;
        }
        public static void Write(string key, string value)
        {
            try
            {
                if (config.AppSettings.Settings[key] != null)
                    config.AppSettings.Settings[key].Value = value;
                else
                    config.AppSettings.Settings.Add(key, value);
                config.Save();
            }
            catch (Exception ex) { }
        }
    }
}
